<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE html>
<html>
<head>
    <title>分享统计</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link type="text/css" rel="stylesheet" href="css/bootstrap.css">
    <link type="text/css" rel="stylesheet" href="css/style.css">
    <link type="text/css" rel="stylesheet" href="css/share.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="layer/layer.js"></script>
    <script type="text/javascript" src="js/share.js"></script>
</head>
<body>

    <!--header-->
    <jsp:include page="/header.jsp"></jsp:include>
    <!--//header-->

    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="page-header">
                    <h2>分享统计 <small>查看热门分享商品</small></h2>
                </div>
            </div>
        </div>
        
        <!-- 分享统计卡片 -->
        <div class="row">
            <div class="col-md-3">
                <div class="panel panel-primary">
                    <div class="panel-heading">
                        <h3 class="panel-title">总分享</h3>
                    </div>
                    <div class="panel-body">
                        <h3 class="text-center">${totalShareCount}</h3>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="panel panel-success">
                    <div class="panel-heading">
                        <h3 class="panel-title">微信分享</h3>
                    </div>
                    <div class="panel-body">
                        <h3 class="text-center">${wechatShareCount}</h3>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="panel panel-danger">
                    <div class="panel-heading">
                        <h3 class="panel-title">微博分享</h3>
                    </div>
                    <div class="panel-body">
                        <h3 class="text-center">${weiboShareCount}</h3>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="panel panel-info">
                    <div class="panel-heading">
                        <h3 class="panel-title">QQ分享</h3>
                    </div>
                    <div class="panel-body">
                        <h3 class="text-center">${qqShareCount}</h3>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 热门分享商品列表 -->
        <div class="row">
            <div class="col-md-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">热门分享商品</h3>
                    </div>
                    <div class="panel-body">
                        <div class="table-responsive">
                            <table class="table table-striped table-hover">
                                <thead>
                                    <tr>
                                        <th>排名</th>
                                        <th>商品图片</th>
                                        <th>商品名称</th>
                                        <th>分类</th>
                                        <th>价格</th>
                                        <th>总分享量</th>
                                        <th>微信</th>
                                        <th>微博</th>
                                        <th>QQ</th>
                                        <th>链接</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <c:forEach items="${hotShareGoodsList}" var="goods" varStatus="status">
                                        <tr>
                                            <td>${status.index + 1}</td>
                                            <td><img src="${goods.cover}" alt="${goods.name}" width="50"></td>
                                            <td><a href="goods_detail?id=${goods.id}">${goods.name}</a></td>
                                            <td>${goods.type.name}</td>
                                            <td>¥${goods.price}</td>
                                            <td>${goods.shareCount}</td>
                                            <td>${goods.wechatShareCount}</td>
                                            <td>${goods.weiboShareCount}</td>
                                            <td>${goods.qqShareCount}</td>
                                            <td>${goods.linkShareCount}</td>
                                            <td>
                                                <button class="btn btn-xs btn-primary" onclick="shareToWechat(${goods.id})">
                                                    <i class="fab fa-weixin"></i> 分享
                                                </button>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 我的分享记录 -->
        <c:if test="${user != null}">
            <div class="row">
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title">我的分享记录</h3>
                        </div>
                        <div class="panel-body">
                            <c:choose>
                                <c:when test="${empty userShareList}">
                                    <div class="alert alert-info">
                                        <p>您还没有分享过商品！</p>
                                    </div>
                                </c:when>
                                <c:otherwise>
                                    <div class="table-responsive">
                                        <table class="table table-striped">
                                            <thead>
                                                <tr>
                                                    <th>商品名称</th>
                                                    <th>分享类型</th>
                                                    <th>分享时间</th>
                                                    <th>操作</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <c:forEach items="${userShareList}" var="share">
                                                    <tr>
                                                        <td><a href="goods_detail?id=${share.goods_id}">${share.goods.name}</a></td>
                                                        <td>
                                                            <c:choose>
                                                                <c:when test="${share.share_type eq 'wechat'}">
                                                                    <span class="label label-success">微信</span>
                                                                </c:when>
                                                                <c:when test="${share.share_type eq 'weibo'}">
                                                                    <span class="label label-danger">微博</span>
                                                                </c:when>
                                                                <c:when test="${share.share_type eq 'qq'}">
                                                                    <span class="label label-info">QQ</span>
                                                                </c:when>
                                                                <c:when test="${share.share_type eq 'link'}">
                                                                    <span class="label label-warning">链接</span>
                                                                </c:when>
                                                                <c:otherwise>
                                                                    <span class="label label-default">${share.share_type}</span>
                                                                </c:otherwise>
                                                            </c:choose>
                                                        </td>
                                                        <td><fmt:formatDate value="${share.share_time}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                                                        <td>
                                                            <a href="goods_detail?id=${share.goods_id}" class="btn btn-xs btn-primary">查看商品</a>
                                                        </td>
                                                    </tr>
                                                </c:forEach>
                                            </tbody>
                                        </table>
                                    </div>
                                </c:otherwise>
                            </c:choose>
                        </div>
                    </div>
                </div>
            </div>
        </c:if>
    </div>

    <!--footer-->
    <jsp:include page="/footer.jsp"></jsp:include>
    <!--//footer-->

</body>
</html> 